package com.bmslz.monitor.controller;

import com.bmslz.monitor.base.annotation.AutoLog;
import com.bmslz.monitor.base.dto.LoginDto;
import com.bmslz.monitor.helper.LoginHelper;
import com.bmslz.monitor.base.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description: 登录
 * @Author: yry
 * @Date: 2025-08-23
 * @Version: V1.0
 */
@Slf4j
@Api(tags = "告警模板")
@RestController
@RequestMapping("/sys/auth")
public class LoginController {
    @Autowired
    private LoginHelper loginHelper;

    /**
     * 登录
     *
     * @param loginDto
     * @return
     */
    @AutoLog(value = "登录")
    @ApiOperation(value = "登录", notes = "登录")
    @PostMapping(value = "/login")
    public Result<?> add(@RequestBody LoginDto loginDto) {
        return Result.OK(loginHelper.login(loginDto));
    }

    /**
     * 登录
     *
     * @return
     */
    @AutoLog(value = "登录用户信息")
    @ApiOperation(value = "登录用户信息", notes = "登录用户信息")
    @GetMapping(value = "/info")
    public Result<?> userInfo() {
        return Result.OK(loginHelper.userInfo());
    }
}
